import { Boolean, Code, Desc, Entity, Jsonb, PrimaryUuid, Title, Uuid } from "@sker/core";

@Entity({
    name: 'core_entity'
})
export class CoreEntity {
    @PrimaryUuid()
    id: string;

    @Code()
    name: string;

    @Title()
    title: string;

    @Desc()
    desc: string;
}

@Entity({
    name: 'core_entity_relation'
})
export class CoreEntityRelation {
    @PrimaryUuid()
    id: string;

    @Uuid({ comment: '所属表' })
    entity_id: string;

    @Code({ comment: '源属性' })
    name: string;

    @Code({
        comment: '源表'
    })
    from_name: string;

    @Code({
        comment: '源表列'
    })
    from_column_name: string;

    @Code({
        comment: '目标表'
    })
    to_name: string;

    @Code({
        comment: '目标表列'
    })
    to_column_name: string;

    @Code({ comment: '关联类型' })
    type: string;

    @Title({ comment: '标题', default: '' })
    title: string;
}

@Entity({
    name: 'core_entity_column',
})
export class CoreEntityColumn {
    @PrimaryUuid()
    id: string;

    @Uuid()
    entity_id: string;

    @Code({ label: '表名', default: '' })
    tablename: string;

    @Boolean({ label: '是否操作', default: false })
    isAction: boolean;

    @Boolean({ label: '是否主键', default: false })
    isPrimary: boolean;

    @Code()
    name: string;

    @Title({
        default: ''
    })
    title: string;

    @Desc({
        default: ''
    })
    desc: string;

    @Code({
        default: ''
    })
    type: string;

    @Jsonb({ comment: '映射值', default: {} })
    valueEnum: any;
}
